﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MediaMonitor.admin
{
    public partial class news_template_list : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblMsg.Text = "";
        }

        protected void btnSearch_Click (object sender, ImageClickEventArgs e)
        {
            sqlDS.SelectCommand = "SELECT * FROM NewsTemplate WHERE TemplateName LIKE '" + tbTemplateName.Text.Trim() + "%' ORDER BY TemplateName";
            gvNewsTemplates.DataBind();
        }


        protected void gv_Delete(object sender, CommandEventArgs e)
        {
            string templateID = e.CommandArgument.ToString();

            try
            {
                Adex.NewsTemplate.Delete(templateID);
                lblMsg.Text = "News Template deleted successfully<br><br>";

                sqlDS.SelectCommand = "SELECT * FROM NewsTemplate WHERE TemplateName LIKE '" + tbTemplateName.Text.Trim() + "%' ORDER BY TemplateName";
                gvNewsTemplates.DataBind();
            }
            catch(Exception ex)
            {
                lblMsg.Text = "Failed to delete. [" + ex.Message + "] ";

            }


            
        }
       
    }
}